<template>
  <div id="contractsTermsFile">
    <div class="messageSwdy">合同模板列表</div>
    <div class="table">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="docName" label="文件名称" width="180" align="center"></el-table-column>
        <el-table-column prop="sNo" label="模板ID" width="180" align="center"></el-table-column>
        <el-table-column prop="type" label="文件类型" align="center"></el-table-column>
        <el-table-column prop="conName" label="合同类型名称" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="choose(scope.row)">选择</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="10"
          layout="total, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "contractsTermsFile",
  data() {
    return {
      tableData: [],
      currentPage: 1,
      total: 0
    };
  },
  created() {
    this.getdata(1);
  },
  methods: {
    choose (pp) {
      let nextdata = sessionStorage.getItem('nextdata');
      let obj = JSON.parse(nextdata);
      obj.templateId = String(pp.docId);
      this.axios.post('AdminAPI/projectContract/addContractInfo', this.filterNoneObj(obj))
        .then(({data})=> {
          if (data.code == 200) {
            this.$message({message: '你已选择'+pp.docName,type: 'success'});
            this.$router.push('contractsList');
          }
        })
    },
    look () {

    },
    getdata(val) {
      this.currentPage = val;
      let obj = {
        page: this.currentPage
      }
      this.axios.get('AdminAPI/projectContract/getTemplateList',{params: this.filterNoneObj(obj)})
        .then(({ data }) => {
          this.tableData = data.data;
          this.total = data.pageInfo.total;
        });
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getdata(val);
    }
  }
};
</script>

<style lang="scss">
#contractsTermsFile {
  .messageSwdy {
    margin-top: 46px;
  }
  .table {
    padding: 48px 76px;
    background: white;
    padding-top: 16px;
    .has-gutter tr th {
      background: #fefaf1;
    }
    .block {
      text-align: right;
      margin-right: 55px;
      height: 50px;
      margin-top: 20px;
    }
  }
  .bottomBtn {
    text-align: center;
    padding: 30px 0;
    button {
      width: 632px;
      height: 50px;
      background: rgba(242, 146, 7, 1);
      box-shadow: 0px 0px 6px 0px rgba(122, 121, 121, 0.5);
      border-radius: 10px;
      cursor: pointer;
      font-size: 22px;
      color: rgba(255, 255, 255, 1);
    }
  }
}
</style>
